<?php
/*
This file is part of Bugzilla Printable Report

    Bugzilla Printable Report  is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Bugzilla Printable Report  is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Bugzilla Printable Report   If not, see <http://www.gnu.org/licenses/>.
*/

//Bug Reports Sample Form

require_once('includes/config.php');

          //create the database object
          $bugsDB =& DB::connect($dsn, $options);

          if (PEAR::isError($bugsDB)) {
              die($bugsDB->getMessage());
          }

          //set the fetchmode to ordered
          $bugsDB->setFetchMode(DB_FETCHMODE_ORDERED);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sample</title>
        <link rel="stylesheet" type="text/css" href="print.css" />
    </head>
    <body>

    <form method="get" action="index.php">
    <table class="sample">
    <tr>
      <th colspan=2>Printable Bug Report Sample Form</th>
    </tr>
    <tr>
      <td>Start Date:</td><td><input type="text" size="12" maxlengtd="15" name="start_date"></td>
    </tr>
    <tr>
      <td>End Date:</td><td><input type="text" size="12" maxlengtd="15" name="end_date"></td>
    </tr>
    <tr>
    <td>Date Type:</td><td><select name="date_type">
          <option value="creation_ts">Creation_ts</option>
          <option value="delta_ts">Delta_ts</option>
          <option value="lastdiffed">Lastdiffed</option>
          <option value="deadline">Deadline</option>
   </select></td>
   </tr>
   <tr>
     <td>Status:</td><td><select name="bug_status[]" multiple size=5>
<?php
    //build the query
    $query = "SELECT value
              FROM bug_status
              ORDER BY id";

   //query the database
   $res =& $bugsDB->query($query);

   if (PEAR::isError($res)) {
         die($res->getMessage());
   }

   while ($res->fetchInto($row)) {

       print '<option ';

             //default NEW,ASSIGNED AND REOPENED
             if($row[0] == 'NEW' || $row[0] == 'ASSIGNED' || $row[0] == 'REOPENED') {
                 print ' selected="" ';
             }

       print 'value="' . $row[0] . '">' . $row[0] . '</option>' . "\n";
   }

?>
     </select></td>
   </tr>
   <tr>
     <td>Product:</td><td><select name="product[]" multiple size=5>
<?php
    //build the query
    $query = "SELECT name
              FROM products
              ORDER BY name";

   //query the database
   $res =& $bugsDB->query($query);

   if (PEAR::isError($res)) {
         die($res->getMessage());
   }

   while ($res->fetchInto($row)) {

       print '<option value="' . $row[0] . '">' . $row[0] . '</option>' . "\n";
   }

?>
     </select></td>
   </tr>
   <tr>
       <td colspan=2 align=center class="sample">Click Submit without entering any values<br>
                                and you will see all open bugs. Start date<br>
                                and End date is optional. A valid date<br>
                                format is (yyyy-mm-dd). </td>
   </tr>
   <tr>
     <td colspan=2 align=center><input type="submit" value="submit"></td>
   </tr>
   <tr>
     <td colspan=2 align=center><a href="<?php print $homepage; ?>">Back to Home</a></td>
   </tr>
   </table>
   </form>

    </body>
</html>
<?php
     $bugsDB->disconnect();
?>